#include "module.h"
#define AUTHOR "Darkwire"
#define VERSION "2.0"

int umode (char *source, int ac, char **av);

int AnopeInit(int argc, char **argv)
{
	EvtHook *hook = NULL;
	Command *c;
	Message * m;
	int status;

	moduleAddAuthor(AUTHOR);
	moduleAddVersion(VERSION);

	m = createMessage("UMODE2",umode);
	moduleAddMessage(m,MOD_TAIL);

	alog("Secure: module loaded");
	
	return MOD_CONT;
}

void AnopeFini(void)
{
	alog("Secure: module unloaded");
}


int umode (char *source, int ac, char **av)
{
	int i, is_oper, now;
	char *c,*c2;
	char * only_admins = "NSh";
	char * only_opers = "oq";
	User * u;

	u = finduser(source);

	if(!u)
		return MOD_CONT;

	if(!av[0])
		return MOD_CONT;

	if(is_services_admin(u))
		return MOD_CONT;

	is_oper=is_services_oper(u);	

	for(c=av[0];*c!='\0';c++)
	{
		if(*c=='-')
			return MOD_CONT;	
			
		for(c2=only_admins; *c2 != '\0'; c2++)
			if(*c==*c2)
				goto take_modes;

		if(!is_oper)
		{
			for(c2=only_opers;*c2!='\0';c2++)
				if(*c==*c2)
					goto take_modes;
		}
		
				
	}
	return MOD_CONT;
	
	take_modes:
	anope_cmd_mode(s_OperServ, source, "-%s",only_admins);	
	anope_cmd_mode(s_OperServ, source, "-%s",only_opers);	
	common_svsmode(u, "-NSoOWqh", NULL);
	anope_cmd_global(s_OperServ, "(\2!\2) flags \2%s\2 have been taken from \2%s!%s@%s\2 server: %s", av[0], u->nick,u->username,u->host,u->server->name) ;
	return MOD_CONT;
}
/**
*EOF
**/
